﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>();
            List<int> odd = new List<int>();
            Random random = new Random();
            while (list1.Count<10)
            {
                int num = random.Next(1, 100);
                if (!list1.Contains(num))
                {
                    list1.Add(num);
                }
            }
            //普通筛选奇数
            //foreach (int item in list1)
            //{
            //    if (item%2 != 0)
            //    {
            //        odd.Add(item);
            //    }
            //}
            #region
            //lamda表达式筛选
            List<int> list2 = list1.Where(x => x%2!=0).ToList();
            #endregion
            foreach (int item in list1)
            {
                Console.Write($"{item} ");
            }
            Console.WriteLine("");
            //foreach (int item in odd)
            //{
            //    Console.Write($"{item} ");
            //}
            int[] oddarray = list2.ToArray();
            foreach (int item in oddarray)
            {
                Console.Write($"{item} ");
            }
            Console.ReadKey();
        }
    }
}
